<?php
if (!defined('ZSM_ROOT_DIR'))  die('Hacking attempt');
/**
 * 模板类
 *
 */
class Template{
	public $layout='0';	
	public $layoutFile='layout.php';
	public $css="\n";
	public $js="\n";	
	public $template_dir = '';
	public $isFileCache = 1;
	public function assign($variable,$values){
		$this->$variable = $values;
	}
	public function display(){		
		$arr = get_object_vars($this);		
		foreach ($arr as $key => $value) {			
		    $$key=$value;
		}	
		if ($this->template_dir!=''){
			$templateFile = $this->template_dir;
		}
		
		if($this->layout=='1'){
			$content =  $this->template_dir;			
			include  ZSM_ROOT_DIR.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$this->layoutFile;
		}else{
			if(file_exists($this->template_dir)){
				include $this->template_dir;	
			}else{
				errors(2003,'zh',$this->template_dir);
			}	
					
		}
	}	
	public function addCss($css){
		
		$css = '<link type="text/css" href="'.$css.'" rel="stylesheet" media="screen" />'." \n";
		$this->css = $this->css.$css;
	}
	public function addJs($js){
		
		$js = '<script type="text/javascript" src="'.$js.'"></script>'." \n";
		$this->js = $this->js.$js;
		
	}
}
?>